package com.twb.core.money;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.twb.core.util.MoneyUtil;
import java.io.IOException;
import org.springframework.boot.jackson.JsonComponent;


/**
 * 金额序列化
 * 分转元
 *
 * @author DHL
 * @date 2022-10-10 12:29:10
 */
@JsonComponent
public class MoneySerializer extends JsonSerializer<Long> {

  @Override
  public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
    gen.writeNumber(MoneyUtil.F2Y(value));
  }
}
